home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
dflat_r_.arc
/
LISTS.C
< prev
next >
Wrap
Text File
|
1991-10-02
|
6KB
|
217 lines
/* --------------- lists.c -------------- */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <dos.h>
#include "dflat.h"
struct LinkedList Focus;
struct LinkedList Built;
/* --- set focus to the window beneath the one specified --- */
void SetPrevFocus(WINDOW wnd)
{
if (wnd != NULLWND && wnd == inFocus) {
WINDOW wnd1 = wnd;
while (TRUE) {
if ((wnd1 = PrevWindow(wnd1)) == NULLWND)
wnd1 = Focus.LastWindow;
if (wnd1 == wnd)
return;
if (wnd1 != NULLWND)
break;
}
if (wnd1 != NULLWND)
SendMessage(wnd1, SETFOCUS, TRUE, 0);
}
}
/* this function assumes that wnd is in the Focus linked list */
static WINDOW SearchFocusNext(WINDOW wnd, WINDOW pwnd)
{
WINDOW wnd1 = wnd;
if (wnd != NULLWND) {
while (TRUE) {
if ((wnd1 = NextWindow(wnd1)) == NULLWND)
wnd1 = Focus.FirstWindow;
if (wnd1 == wnd)
return NULLWND;
if (wnd1 != NULLWND)
if (pwnd == NULLWND || pwnd == GetParent(wnd1))
break;
}
}
return wnd1;
}
/* ----- set focus to the next sibling ----- */
void SetNextFocus(WINDOW wnd)
{
WINDOW wnd1;
if (wnd != inFocus)
return;
if ((wnd1 = SearchFocusNext(wnd, GetParent(wnd)))==NULLWND)
wnd1 = SearchFocusNext(wnd, NULLWND);
if (wnd1 != NULLWND)
SendMessage(wnd1, SETFOCUS, TRUE, 0);
}
/* ---- remove a window from the Built linked list ---- */
void RemoveBuiltWindow(WINDOW wnd)
{
if (wnd != NULLWND) {
if (PrevWindowBuilt(wnd) != NULLWND)
NextWindowBuilt(PrevWindowBuilt(wnd)) =
NextWindowBuilt(wnd);
if (NextWindowBuilt(wnd) != NULLWND)
PrevWindowBuilt(NextWindowBuilt(wnd)) =
PrevWindowBuilt(wnd);
if (wnd == Built.FirstWindow)
Built.FirstWindow = NextWindowBuilt(wnd);
if (wnd == Built.LastWindow)
Built.LastWindow = PrevWindowBuilt(wnd);
}
}
/* ---- remove a window from the Focus linked list ---- */
void RemoveFocusWindow(WINDOW wnd)
{
if (wnd != NULLWND) {
if (PrevWindow(wnd) != NULLWND)
NextWindow(PrevWindow(wnd)) = NextWindow(wnd);
if (NextWindow(wnd) != NULLWND)
PrevWindow(NextWindow(wnd)) = PrevWindow(wnd);
if (wnd == Focus.FirstWindow)
Focus.FirstWindow = NextWindow(wnd);
if (wnd == Focus.LastWindow)
Focus.LastWindow = PrevWindow(wnd);
}
}
/* ---- append a window to the Built linked list ---- */
void AppendBuiltWindow(WINDOW wnd)
{
if (wnd != NULLWND) {
if (Built.FirstWindow == NULLWND)
Built.FirstWindow = wnd;
if (Built.LastWindow != NULLWND)
NextWindowBuilt(Built.LastWindow) = wnd;
PrevWindowBuilt(wnd) = Built.LastWindow;
NextWindowBuilt(wnd) = NULLWND;
Built.LastWindow = wnd;
}
}
/* ---- append a window to the Focus linked list ---- */
void AppendFocusWindow(WINDOW wnd)
{
if (wnd != NULLWND) {
if (Focus.FirstWindow == NULLWND)
Focus.FirstWindow = wnd;
if (Focus.LastWindow != NULLWND)
NextWindow(Focus.LastWindow) = wnd;
PrevWindow(wnd) = Focus.LastWindow;
NextWindow(wnd) = NULLWND;
Focus.LastWindow = wnd;
}
}
/* -------- get the first child of a parent window ------- */
WINDOW GetFirstChild(WINDOW wnd)
{
WINDOW ThisWindow = Built.FirstWindow;
while (ThisWindow != NULLWND) {
if (GetParent(ThisWindow) == wnd)
break;
ThisWindow = NextWindowBuilt(ThisWindow);
}
return ThisWindow;
}
/* -------- get the next child of a parent window ------- */
WINDOW GetNextChild(WINDOW wnd, WINDOW ThisWindow)
{
if (ThisWindow != NULLWND) {
do {
if ((ThisWindow = NextWindowBuilt(ThisWindow)) !=
NULLWND)
if (GetParent(ThisWindow) == wnd)
break;
} while (ThisWindow != NULLWND);
}
return ThisWindow;
}
/* -- get first child of parent window from the Focus list -- */
WINDOW GetFirstFocusChild(WINDOW wnd)
{
WINDOW ThisWindow = Focus.FirstWindow;
while (ThisWindow != NULLWND) {
if (GetParent(ThisWindow) == wnd)
break;
ThisWindow = NextWindow(ThisWindow);
}
return ThisWindow;
}
/* -- get next child of parent window from the Focus list -- */
WINDOW GetNextFocusChild(WINDOW wnd, WINDOW ThisWindow)
{
while (ThisWindow != NULLWND) {
ThisWindow = NextWindow(ThisWindow);
if (ThisWindow != NULLWND)
if (GetParent(ThisWindow) == wnd)
break;
}
return ThisWindow;
}
/* -------- get the last child of a parent window ------- */
WINDOW GetLastChild(WINDOW wnd)
{
WINDOW ThisWindow = Built.LastWindow;
while (ThisWindow != NULLWND) {
if (GetParent(ThisWindow) == wnd)
break;
ThisWindow = PrevWindowBuilt(ThisWindow);
}
return ThisWindow;
}
/* ------- get the previous child of a parent window ------- */
WINDOW GetPrevChild(WINDOW wnd, WINDOW ThisWindow)
{
if (ThisWindow != NULLWND) {
do {
if ((ThisWindow = PrevWindowBuilt(ThisWindow)) !=
NULLWND)
if (GetParent(ThisWindow) == wnd)
break;
} while (ThisWindow != NULLWND);
}
return ThisWindow;
}
/* --- bypass system windows when stepping through focus --- */
void SkipSystemWindows(int Prev)
{
int cl, ct = 0;
while ((cl = GetClass(inFocus)) == MENUBAR ||
cl == APPLICATION
#ifdef INCLUDE_STATUSBAR
|| cl == STATUSBAR
#endif
) {
if (Prev)
SetPrevFocus(inFocus);
else
SetNextFocus(inFocus);
if (++ct == 3)
break;
}
}